from Tkinter import *
import math

canvas = Canvas(width=300, height=300, bg='white')

x = 150
y = 150

canvas.pack(expand=YES, fill=BOTH)                  
canvas.create_oval(x-1,y-1,x+1,y+1)

class Snowflake():
    def __init__(self, angle, length, level):
        self.a = angle
        self.l = length
        self.N = level
        self.xn = []
        self.yn = []
        
    def newCenterPoints(self, x, y, l):
        """new center points"""
        
        a = math.radians(self.a)
     
        self.xn.append(x+l*math.sin(a))
        self.yn.append(y+l*math.cos(a))
        
        self.xn.append(x-l*math.sin(a))
        self.yn.append(y-l*math.cos(a))
        
        self.xn.append(x+l*math.sin(a))
        self.yn.append(y-l*math.cos(a))
        
        self.xn.append(x-l*math.sin(a))
        self.yn.append(y+l*math.cos(a))
        
        self.xn.append(x)
        self.yn.append(y+l)
        
        self.xn.append(x)
        self.yn.append(y-l)
        
        return self.xn, self.yn
        
    
    def drawSnowflake(self):
        a = math.radians(self.a)
        canvas.create_line(x, y, x+self.l*math.sin(a), y+self.l*math.cos(a))        
        canvas.create_line(x, y, x-self.l*math.sin(a), y-self.l*math.cos(a))
        canvas.create_line(x, y, x+self.l*math.sin(a), y-self.l*math.cos(a))
        canvas.create_line(x, y, x-self.l*math.sin(a), y+self.l*math.cos(a))         
        canvas.create_line(x, y, x, y+self.l)
        canvas.create_line(x, y, x, y-self.l)
          
        k = 0
        
        self.newCenterPoints(x, y, self.l)
        
        while k < self.N:
            
            self.l = self.l/5
                        
            for i in range(0,len(self.xn)):
                canvas.create_oval(self.xn[i]-1,self.yn[i]-1,self.xn[i]+1,self.yn[i]+1)
                canvas.create_line(self.xn[i], self.yn[i], self.xn[i]+self.l*math.sin(a), self.yn[i]+self.l*math.cos(a))        
                canvas.create_line(self.xn[i], self.yn[i], self.xn[i]-self.l*math.sin(a), self.yn[i]-self.l*math.cos(a))
                canvas.create_line(self.xn[i], self.yn[i], self.xn[i]+self.l*math.sin(a), self.yn[i]-self.l*math.cos(a))
                canvas.create_line(self.xn[i], self.yn[i], self.xn[i]-self.l*math.sin(a), self.yn[i]+self.l*math.cos(a))         
                canvas.create_line(self.xn[i], self.yn[i], self.xn[i], self.yn[i]+self.l)
                canvas.create_line(self.xn[i], self.yn[i], self.xn[i], self.yn[i]-self.l) 
                
                self.newCenterPoints(self.xn[i], self.yn[i], self.l)
                
            k += 1
        
s = Snowflake(60, 150, 6)

s.drawSnowflake()

    
mainloop()